package pl.kosmowska.ewelina.server.jdo;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Version;
import javax.jdo.annotations.VersionStrategy;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
@PersistenceCapable
@Version(strategy = VersionStrategy.VERSION_NUMBER, extensions = { @Extension(vendorName = "datanucleus", key = "key", value = "version") })

public class CategoryItemData implements DatabaseEntity<String>{


	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;

	@Persistent
	private Long version;


	@Persistent
	private Long userId;

	@Persistent
	private String name;

	@Persistent
	private boolean defaultCategory;

	public void setId(Key parentKey, String id) {
		if (parentKey == null) {
			return;
		}
		if (id != null) {
			setId(id);
		} else {
			key = KeyFactory.createKey(parentKey, CategoryItemData.class.getName(), null);
		}
	}
	public void setId(String id) {
		key = KeyFactory.stringToKey(id);
	}
	public String getId() {
		String id = null;
		if (key != null) {
			id = KeyFactory.keyToString(key);
		}
		return id;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}
	public Long getUserId() {
		return userId;
	}

	public void setVersion(Long version) {
		this.version = version;
	}
	public Long getVersion() {
		if (version == null) {
			return 0l;
		}
		return version;
	}

	public void setName(String name) {
		this.name = name;
	}
	public String getName() {
		return name;
	}
	public boolean isDefaultCategory() {
		return defaultCategory;
	}
	public void setDefaultCategory(boolean defaultCategory) {
		this.defaultCategory = defaultCategory;
	}



}